package homework1;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Demo {

    /**
     * 判断数组中是否所有数字只出现过一次
     * @param array
     * @return
     */
    public static String judgeAppearOnce(int[] array){
        //创建list存储每个数字
        List<Integer> list = new ArrayList<Integer>();
        for (int i : array) {
            if (! list.contains(i)){
                //list中不包含i，则存入i
                list.add(i);
            }else{
                //如果list中包含i,说明i个数超过1个,直接返回false
                return "NO";
            }
        }
        return "YES";
    }

    public static void main(String[] args) {
        int[] array1 = {1, 2, 3};
        System.out.println(judgeAppearOnce(array1));
        int[] array2 = {1, 2, 1};
        System.out.println(judgeAppearOnce(array2));
    }
}
